﻿using System.IO;
using System.Security.Cryptography;
using PhiStore.Security;

namespace PhiStore.Experiments.Encryption
{
    class DES
    {
        ICryptoTransform encrypter;
        ICryptoTransform decrypter;

        public DES(string pass)
        {
            DESCryptoServiceProvider provider = new DESCryptoServiceProvider();

            byte[] KeyBytes = Helper.GenerateKey(pass, 64);
            provider.Key = KeyBytes;

            encrypter = provider.CreateEncryptor();
            decrypter = provider.CreateDecryptor();
        }

        public Stream Encrypt(Stream input)
        {
            return GenericEncryption.Encrypt(input, encrypter);
        }

        public Stream Decrypt(Stream input)
        {
            return GenericEncryption.Encrypt(input, decrypter);
        }
    }
}
